# -*- coding: utf-8 -*-
# !/usr/resources/python3

from models.Model import Model
from sqlalchemy import and_
from models.ResourceChapter import ResourceChapterModel as Chapter

# model
model = Model()


class ChapterProcessing:
    # 获取章节设定
    @staticmethod
    def get_chapter_setting(resource_id):
        chapters = model.all_order(Chapter, and_(
            Chapter.resource_id == resource_id
        ), Chapter.line.asc())
        setting = {}
        for j in chapters:
            setting[j.line] = {
                'id': j.id,
                'is_end': j.is_end
            }

        return setting
